package com.student.management.root.dao.impl;

import com.student.management.root.bean.Menu;
import com.student.management.root.dao.MenuDao;
import com.student.management.root.utils.DBUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class MenuDaoImpl extends DBUtils implements MenuDao {
    @Override
    public List<Menu> getMenuList() {
        List mu=new ArrayList();
        try {
            String sql = "SELECT * FROM menu WHERE 1=1;";
            resultSet = query(sql, null);
            while (resultSet.next()){
                Menu menu = new Menu();
                menu.setMenuid(resultSet.getInt("menuid"));
                menu.setMenuname(resultSet.getString("menuname"));
                menu.setUpmenuid(resultSet.getInt("upmenuid"));
                menu.setState(resultSet.getInt("state"));
                menu.setDesc(resultSet.getString("desc"));
                menu.setUrl(resultSet.getString("url"));
                mu.add(menu);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            closeAll();
        }
        return mu;
    }
}
